package com.huawei.edukids;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager.TaskDescription;
import android.content.Context;
import android.content.IntentFilter;
import android.os.AsyncTask;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.provider.Settings.Global;
import android.view.KeyEvent;
import android.view.Menu;
import android.widget.ImageView;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.activity.AbstractBaseActivity;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment.b;
import com.huawei.appgallery.foundation.ui.framework.fragment.LoadingFragment;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse;
import com.huawei.appmarket.R;
import com.huawei.appmarket.framework.MainActivityBase;
import com.huawei.appmarket.framework.fragment.HasTitleLoadingFragment;
import com.huawei.appmarket.framework.startevents.bean.CountryInfo;
import com.huawei.appmarket.framework.startevents.protocol.ServiceZoneSwitchActivityProtocol;
import com.huawei.appmarket.framework.startevents.protocol.ServiceZoneSwitchActivityProtocol.Request;
import com.huawei.appmarket.service.common.protocol.AppActivityProtocol;
import com.huawei.appmarket.service.plugin.receiver.CommonActivityReceiver;
import com.huawei.appmarket.support.widget.tabhost.FragmentTabHost;
import huawei.widget.HwBottomNavigationView;
import java.util.ArrayList;
import java.util.List;
import o.AccountBussinessListener;
import o.ccp;
import o.ceh;
import o.PermissionChecker;
import o.cjk;
import o.cjm;
import o.cjo;
import o.cks;
import o.cuh;
import o.cxx;
import o.dgh;
import o.dgm;
import o.Logger;
import o.doo;
import o.ContentManager;
import o.dzt;
import o.dzu;
import o.emw;
import o.enc;
import o.eod;
import o.eoj;
import o.eox;
import o.CollectCheck;
import o.erz;
import o.euf;
import o.ActivityUtil;
import o.evr;
import o.ext;
import o.exv;
import o.exx;
import o.exz;
import o.exz.a;

public abstract class AbstractEduKidsMainActivity extends MainActivityBase<AppActivityProtocol> implements ceh {
    private int ʾ = UserSession.getInstance().getStatus();
    private String ʿ = "";
    private AccountBussinessListener ˊˊ = new d();
    private boolean ˊˋ = false;
    private CommonActivityReceiver ˊॱ;
    private cxx ˊᐝ;

    class d implements AccountBussinessListener {
        final /* synthetic */ AbstractEduKidsMainActivity ˏ;

        private d(AbstractEduKidsMainActivity abstractEduKidsMainActivity) {
            this.ˏ = abstractEduKidsMainActivity;
        }

        public void onAccountBusinessResult(ccp o_ccp) {
            Logger.ˎ("AbstractEduKidsActivity", "mustLogin() onAccountBusinessResult accountResult.resultCode=" + o_ccp.ˎ);
            if (102 != o_ccp.ˎ) {
                this.ˏ.ˊ(true);
                this.ˏ.finish();
            }
            eoj.ˋ().ˊ("centerForceLogin");
        }
    }

    public abstract void ˊˊ();

    public abstract void ᐝˊ();

    public abstract String ᐝˋ();

    public abstract ext ᐨ();

    public abstract String ᶥ();

    public abstract String ㆍ();

    public abstract Class<?> ꓸ();

    public abstract String ꜟ();

    public void onCreate(Bundle bundle) {
        ˊˊ();
        super.onCreate(bundle);
        PermissionChecker.ˎ(this, 14);
        ॱ((Activity) this);
        AppActivityProtocol appActivityProtocol = (AppActivityProtocol) ʾ();
        if (!(appActivityProtocol == null || appActivityProtocol.ˋ() == null)) {
            this.ʿ = ((AppActivityProtocol) ʾ()).ˋ().ˏ();
            if ("26".equals(this.ʿ)) {
                dgh.ॱ(this, "310601", "0");
            }
        }
        setTaskDescription(new TaskDescription(ᶥ()));
    }

    public void ᐝ() {
        setContentView(R.layout.market_activity);
        this.tabHost = (FragmentTabHost) findViewById(16908306);
        this.ˏॱ = (ImageView) findViewById(R.id.skin_image);
        ꜞ();
    }

    public int ͺ() {
        return R.id.main_view_layout;
    }

    public void ˍ() {
    }

    private void ꜞ() {
        this.mBottomNavigationView = (HwBottomNavigationView) findViewById(R.id.hiapp_mainscreen_bottomtab);
        wrapperNavigator(this.mBottomNavigationView);
    }

    public void onDestroy() {
        ᐝˊ();
        super.onDestroy();
        ActivityUtil.unregisterReceiver(this, this.ˊॱ);
    }

    public void excuteStateOfLogin(StartupResponse startupResponse) {
        emw.ˊ(dgm.ˎ(this));
        new enc().ˏ();
        if (this.ʾ == 4) {
            Logger.ˎ("GLOBAL_START_FLOW", "AbstractEduKidsActivity FLOW_END excuteStateOfLogin");
            eox.ˎ(ContentManager.getInstant().getContext(), false);
        }
        if (euf.ˎ().ˏ()) {
            Logger.ˏ("AbstractEduKidsActivity", "getTokenAsyn!");
            new cuh().ˏ();
            return;
        }
        Logger.ˏ("AbstractEduKidsActivity", "Push msg flag false!");
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        return super.onCreateOptionsMenu(menu);
    }

    public void onResume() {
        super.onResume();
        ﹳ();
    }

    public TaskFragment ॱˊ() {
        if (doo.ˊ(this)) {
            return new LoadingFragment();
        }
        Bundle bundle = new Bundle();
        bundle.putString("loading_title", ᶥ());
        TaskFragment hasTitleLoadingFragment = new HasTitleLoadingFragment();
        hasTitleLoadingFragment.ʼ(bundle);
        return hasTitleLoadingFragment;
    }

    public boolean ˋ(TaskFragment taskFragment, StartupResponse startupResponse) {
        return false;
    }

    public void ॱ(TaskFragment taskFragment) {
        if (taskFragment instanceof LoadingFragment) {
            ((LoadingFragment) taskFragment).a_(8);
        }
    }

    public int ᐝॱ() {
        return R.id.mainwindows_layout;
    }

    @TargetApi(23)
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        if (14 == i && iArr != null && iArr.length != 0) {
            PermissionChecker.ˎ(this, i, strArr, iArr);
        }
    }

    private void ॱ(Activity activity) {
        this.ˊॱ = new CommonActivityReceiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.huawei.hwid.ACTION_REMOVE_ACCOUNT");
        ActivityUtil.registerReceiver(activity, intentFilter, this.ˊॱ);
    }

    public void ˏ(int i, int i2) {
        if (i2 == -1) {
            AbstractBaseActivity.sendUpgrade(this);
        }
    }

    public void ˎ(StartupResponse startupResponse, int i) {
        Logger.ˎ("AbstractEduKidsActivity", " not support service");
        CountryInfo ʻ = startupResponse.ʻ();
        if (ʻ != null) {
            List ˋ = ʻ.ˋ();
            if (CollectCheck.isEmpty(ˋ)) {
                dzu.ॱ(new ArrayList(), i);
                Logger.ˎ("AbstractEduKidsActivity", " countryList is empty.");
            } else {
                Logger.ˎ("AbstractEduKidsActivity", " countryList is not empty.");
                dzu.ॱ(ˋ, i);
            }
        } else {
            Logger.ˎ("AbstractEduKidsActivity", " countryInfo is empty.");
        }
        ˎ((Context) this);
        finish();
    }

    private void ˎ(Context context) {
        cjo serviceZoneSwitchActivityProtocol = new ServiceZoneSwitchActivityProtocol();
        serviceZoneSwitchActivityProtocol.ॱ(new Request());
        serviceZoneSwitchActivityProtocol.ॱ().ˋ(ᐝˋ());
        serviceZoneSwitchActivityProtocol.ॱ().ˊ(ᶥ());
        serviceZoneSwitchActivityProtocol.ॱ().ˏ(dgm.ˎ(this));
        cjk.ˎ().ˋ(context, new cjm("servicezoneswitch.activity", serviceZoneSwitchActivityProtocol));
    }

    public boolean ˋ(TaskFragment taskFragment, b bVar) {
        boolean ˋ = super.ˋ(taskFragment, bVar);
        dzt.ˎ();
        return ˋ;
    }

    public void forceLogin() {
        Logger.ˎ("AbstractEduKidsActivity", "mustLogin() ");
        eoj.ˋ().ˎ("centerForceLogin", this.ˊˊ);
        eod.ॱ(getApplicationContext());
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        boolean z = false;
        if (i != 4) {
            return super.onKeyDown(i, keyEvent);
        }
        if (evr.ˊ().ʽ()) {
            return true;
        }
        if ("26".equals(this.ʿ)) {
            ˊ(true);
            return super.onKeyDown(i, keyEvent);
        }
        if (Global.getInt(getApplicationContext().getContentResolver(), "hwkidsmode_running", 0) == 1) {
            z = true;
        }
        Logger.ˏ("AbstractEduKidsActivity", "isKidMode = " + z);
        if (z) {
            ˊ(true);
            return super.onKeyDown(i, keyEvent);
        } else if (!erz.ˏ(this, "com.huawei.educenter") || VERSION.SDK_INT >= 26 || !this.ˊˋ || exv.ˎ(ꜟ())) {
            return super.onKeyDown(i, keyEvent);
        } else {
            Logger.ˏ("AbstractEduKidsActivity", "createExitDialog()");
            new exx(this, ᐨ(), ㆍ(), this.ˊᐝ).ˎ(this, new cks(this) {
                final /* synthetic */ AbstractEduKidsMainActivity ॱ;

                {
                    this.ॱ = r1;
                }

                public void enableNetworking() {
                    this.ॱ.ˊ(true);
                    this.ॱ.finish();
                }

                public void upgrade() {
                    this.ॱ.ˊ(true);
                    this.ॱ.finish();
                }

                public void ˋ() {
                }
            }, ꓸ());
            return true;
        }
    }

    private void ﹳ() {
        if (!exv.ˎ(exv.ˏ(this) + ꜟ())) {
            new exz(this, ꜟ(), new a(this) {
                final /* synthetic */ AbstractEduKidsMainActivity ˋ;

                {
                    this.ˋ = r1;
                }

                public void ˏ(cxx o_cxx) {
                    if (o_cxx != null) {
                        this.ˋ.ˊˋ = true;
                        this.ˋ.ˊᐝ = o_cxx;
                    }
                    Logger.ˎ("AbstractEduKidsActivity", "checkShortcutExist isShortCutExit: " + this.ˋ.ˊˋ);
                }
            }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
        }
    }
}
